/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Modelo.DAL;

/**
 *
 * @author Gustavo Pastorelli
 */
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;

//Clase que se conecta a la base de datos usando Hibernate.
public class ConexionBD {

    public Connection session = null;
    private String database = "sigsiusb";
    private String url = "jdbc:postgresql://localhost:5432/" + database;
    private String user = "sigsiusb";
    private String pwd = "sigsiusb";

    //Constructor de la clase.
    public ConexionBD() {
        try {
            Class.forName("org.postgresql.Driver");
        } catch (ClassNotFoundException cnfe) {
            System.out.println("Couldn't find the driver!");
            //System.out.println(cnfe.getMessage());
        }
        try {
            this.session = DriverManager.getConnection(url, user, pwd);
        } catch (SQLException se) {
            System.out.println("Couldn't connect to database!");
            //System.out.println(cnfe.getMessage());
        }
    }

    public void cerrarConexion() {
        try {
            this.session.close();
        } catch (java.sql.SQLException sql) {
            System.out.println("No hay conexion");
        }
    }
}
